package net.tycmc.cty.ctyms.timejob.iems.service;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


import com.tycmc.functions.util.NumberFormat;
import com.tycmc.functions.util.StringUtil;
import net.tycmc.bulb.common.util.DateUtil;
import net.tycmc.bulb.common.util.MapGetter;
import net.tycmc.cty.ctyms.timejob.common.DateRegUtil;
import net.tycmc.cty.ctyms.timejob.common.ExceptionDataProcess;
import net.tycmc.cty.ctyms.timejob.common.ListUtil;
import net.tycmc.cty.ctyms.timejob.common.UnifideCaculation;
import net.tycmc.cty.ctyms.timejob.iems.dao.DrivingBehaviorScoreDAO;
import net.tycmc.cty.ctyms.timejob.iems.dao.WeChatpublicaccountScoreDAO;
/**
 * @author gaoxiaoxing
 *天远微信公众账户发短信
 */
public class WeChatpublicaccountScoreJobService {
	
	private  WeChatpublicaccountScoreDAO wcpbsd;

	public WeChatpublicaccountScoreDAO getWcpbsd() {
		return wcpbsd;
	}

	public void setWcpbsd(WeChatpublicaccountScoreDAO wcpbsd) {
		this.wcpbsd = wcpbsd;
	}

	/**
	 * 微信公众号开始
	 * 
	 **/
	public void startWeChat() {
		List<String> sqlList = new ArrayList<String>();
		List<Object[]> paramsList = new ArrayList<Object[]>();
		//判断是否要执行
		List<Map<String,Object>>list=wcpbsd.getNextTime();
		String dtime=DateUtil.addDay(0).substring(0,10);
		if(list.size()==0||(list.size()>0&&DateRegUtil.compare(dtime,MapGetter.getString(list.get(0),"ntime"),"yyyy-MM-dd"))){
			boolean flag= wcpbsd.getWeChatpublicaccount(sqlList,paramsList);
			if(flag==true){
				//若执行成功，将下次执行时间更新进去
				String ntime=DateUtil.addDay(14);
				wcpbsd.saveNextOprTime(ntime);
				System.out.println("本次更新成功-------------"+sqlList.size()+"条");
			}else{
				System.out.println("本次更新失败-------------"+sqlList.size()+"条");
			}
		}else{
			System.out.println("------------下次执行时间-------------"+MapGetter.getString(list.get(0),"ntime"));
		}
  }
}
